﻿using System;
using System.ComponentModel;
using System.Text;
using System.Xml.Serialization;
using XCode;
using NewLife.Log;

namespace BingZi.HY.Core
{
 
    /// <summary>
    ///初始化数据
    /// </summary>
    public partial class sys_Applications<TEntity>
    {
        #region 数据
        /// <summary>
        /// 首次连接数据库时初始化数据，仅用于实体类重载，用户不应该调用该方法
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)]
        protected override void InitData()
        {
            
            base.InitData();

            if (Meta.Count > 0) return;

            if (XTrace.Debug) XTrace.WriteLine("开始初始化{0}应用管理数据……", typeof(TEntity).Name);

          

            Meta.BeginTrans();
            try
            {
           
                //创建两个应用的初始化数据
                TEntity entity = new TEntity();
                entity.A_AppName = "基础模组";
                entity.A_AppDescription = "基础模组成部分";
                entity.A_AppUrl = "http://Www.Bfb123.Com";
                entity.A_Order = 0;
                entity.Save();

                entity = new TEntity();
                entity.A_AppName = "扩展应用";
                entity.A_AppDescription = "对框架的二次开发部分";
                entity.A_AppUrl = "http://Www.Bfb123.Com";
                entity.A_Order = 1;
                entity.Save();

                //entity = new TEntity();
                //entity.A_AppName = "行业应用(管理员)";
                //entity.A_AppDescription = "行业应用(管理员)  组成部分";
                //entity.A_AppUrl = "http://Www.Bfb123.Com";
                //entity.A_Order = 2;
                //entity.Save();

                Meta.Commit();
            }
            catch { Meta.Rollback(); throw; }

            if (XTrace.Debug) XTrace.WriteLine("完成初始化{0}应用管理数据！", typeof(TEntity).Name);
        }
        #endregion
    }
}
